 public class BurglarProofDoor extends Door implements Lock,Camera{
    private String code;
    private int judgement = -1;
    private String housenumber;
    Handle handle;//先不对门把手序列号进行初始化

    //用于调用的构造方法
    public BurglarProofDoor(){
        
    }
    //物业后台-防盗门初始化
    public BurglarProofDoor(String code,String owner,String housenumber){
        super(owner);
        this.code =code;
        this.housenumber= housenumber;
    }

    //物业后台-门把手初始化 门牌号赋值
    public class Handle{
        public Handle(){

        }
        public void turn(){
            System.out.println("##Welcome to use the Security System##"); 
            System.out.println("Dear " + BurglarProofDoor.this.getOwner() + ",");
        }
    }
    public void turnHandle() {
        handle = new Handle();
        handle.turn();
    }
    

    //开门关门
    public void open(){
        this.turnHandle();
        System.out.println("room "+ this.getHousenumber());
        System.out.println("Welcome,"+ this.getOwner());
    }
    public void close() {
        this.turnHandle();
        System.out.println("room "+ this.getHousenumber());
        System.out.println("Get locked," +this.getOwner());
    }

    //物业后台-防盗门密码设置
    public void setCode(String code){
        this.code = code;
        code.hashCode();
    }

    public void monitor() {
        System.out.println("Camera is still watching");
    }

    //物业后台-用户入住
    public void setHousenumber(String housenumber) {
        this.housenumber =housenumber;
    }
        public String getHousenumber(){
        return housenumber;
    }

    //用户前台-防盗功能
    public int checkCode(String _code){
        if(_code.equals(code)){
            return 1;
        }
        else{
            return -1;
        }
    }

    //上锁和解锁的方法
    public void unlock(String _code){
        judgement = this.checkCode(_code);
        if(judgement == 1){
            System.out.println("Access Granted");
            this.open();
        }
        else
        return;
    }
    public void lock(String _code){
        judgement = this.checkCode(_code);
        if(judgement == -1){
            System.out.println("Error");
            this.close();
        }
        else
        return;
    }
        
        
}


